fix(ingestor): bound neighbor-edges builder scan to retention window#1331
Closed
efiten wants to merge 1 commit into
Closed
fix(ingestor): bound neighbor-edges builder scan to retention window#1331efiten wants to merge 1 commit into
efiten wants to merge 1 commit into
Conversation
buildAndPersistNeighborEdges() was doing a full unbounded JOIN across
observations+transmissions every 60s. On a 9.7GB live DB this query
runs for several minutes, serialising the ingestor's SQLite write path
and starving MQTT ingestion — triggering the watchdog every ~60–90s.
Add a lookbackSecs parameter (derived from NeighborEdgesDaysOrDefault,
default 5 days) and filter `WHERE o.timestamp > strftime('%s','now') - ?`.
The existing idx_observations_timestamp index makes this efficient.
Historical edges already in neighbor_edges are preserved by the ON
CONFLICT upsert; only the incremental scan window shrinks.
Fix test: seed observation with time.Now().Unix() so it falls inside
the lookback window, and pass 7*86400 as the lookback argument.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
Author
|
Superseded by #1341 which was merged upstream with a better watermark/delta approach. The fix has been hot-deployed to live. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
buildAndPersistNeighborEdges()ran an unboundedJOIN observations+transmissionsevery 60s with noWHEREclauseFix
Add
lookbackSecs int64parameter toStartNeighborEdgesBuilderandbuildAndPersistNeighborEdges. The query now filters:The lookback is derived from
NeighborEdgesDaysOrDefault()(default 5 days), matching the existing edge retention window. Theidx_observations_timestampindex (already present) makes this efficient regardless of DB size.Historical edges already in
neighbor_edgesare preserved by theON CONFLICT DO UPDATEupsert — only the incremental scan window shrinks.Test plan
TestNeighborEdgesBuilderUpsertsFromObservationsupdated: observation seeded withtime.Now().Unix()so it falls inside the lookback window; lookback arg7*86400passed explicitlygo test ./...)[neighbor-build]log line now includeslookback=5d; MQTT watchdog stops firing🤖 Generated with Claude Code